# !/usr/bin/env python
# -- coding: utf-8 --
# @Author zengxiaohui
# Datatime:8/25/2021 1:21 PM
# @File:删除数据集中某个文件夹中已有的图片
import os
import shutil
import cv2
from imutils import paths
import yaml
from tqdm import tqdm

if __name__ == '__main__':
    datasets_dir = r"/home/zengxh/medias/data/ext/creepageDistance/lab_datasets"
    cleanPathDir = r"/home/zengxh/medias/data/ext/creepageDistance/双波图片"


    datasetPaths = list(paths.list_images(datasets_dir))
    cleanPaths = list(paths.list_images(cleanPathDir))

    cleanNames = [os.path.split(cleanPath)[1] for cleanPath in cleanPaths]

    # 去重
    for datasetPath in tqdm(datasetPaths):
        _, datasetName = os.path.split(datasetPath)
        if datasetName in cleanNames:
            os.remove(datasetPath)
            os.remove(datasetPath.replace(".jpg", ".json"))